/* Copyright (c) 2011 Jordan Gray, MIT; see COPYRIGHT */


#ifndef RINT_H_
#define RINT_H_

#include <algorithm>

namespace ch11ex04 {

class RINT {
public:
  RINT(int integer=0) : integer_(integer) {
    std::cout << "constructor, assigned " << integer << std::endl;
  }
  RINT(const RINT& rint) : integer_(rint.integer_) {
    std::cout << "copy constructor, assigned " << integer_ << std::endl;
  }
  RINT& operator++() {
    integer_ += 1;
    return *this;
  }
  RINT& operator--() {
    integer_ -= 1;
    return *this;
  }
  RINT operator++(int) {
    RINT temp_integer = integer_;
    integer_ += 1;
    return temp_integer;
  }
  RINT operator--(int) {
    RINT temp_integer = integer_;
    integer_ -= 1;
    return temp_integer;
  }
  RINT& operator+=(const RINT& rint) {
    integer_ += rint.integer_;
    return *this;
  }
  RINT operator+(const RINT& rint) const {
    return RINT(integer_ + rint.integer_);
  }
  RINT& operator-=(const RINT& rint) {
    integer_ -= rint.integer_;
    return *this;
  }
  RINT operator-(const RINT& rint) const {
    return RINT(integer_ - rint.integer_);
  }
  bool operator==(const RINT& rint) const {
    std::cout << "op==" << std::endl;
    return (integer_==rint.integer_);
  }
  bool operator!=(const RINT& rint) const {
    std::cout << "op==" << std::endl;
    return (integer_!=rint.integer_);
  }
  RINT& operator=(RINT rint) {
    std::swap(integer_,rint.integer_);
    std::cout << "op=" << integer_ << std::endl;
    return *this;
  }
  RINT& operator*=(const RINT& rint) {
    integer_ *= rint.integer_;
    return *this;
  }
  RINT operator*(const RINT& rint) const {
    return RINT(integer_ * rint.integer_);
  }
  RINT& operator/=(const RINT& rint) {
    integer_ /= rint.integer_;
    return *this;
  }
  RINT operator/(const RINT& rint) const {
    return RINT(integer_ / rint.integer_);
  }
  friend RINT operator+(const int integer, const RINT& rint) {
    return RINT(integer)+rint;
  }
  friend RINT operator-(const int integer, const RINT& rint) {
    return RINT(integer)-rint;
  }
  friend RINT operator*(const int integer, const RINT& rint) {
    return RINT(integer)*rint;
  }
  friend RINT operator/(const int integer, const RINT& rint) {
    return RINT(integer)/rint;
  }
  //RINT operator+()
private:
  int integer_;
};

} // namespace ch11ex04

#endif /* RINT_H_ */
